package com.aaa.dao;

import com.aaa.pojo.Change;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ChangeMapper {
//    查询全部
    @Select("select * from change_money c,investment_horizon h where c.h_id=h.h_id ORDER BY c_id")
    List<Change> selectAll();
//    添加
    @Insert("insert into change_money(c_name,c_yield,c_earnings,c_amount,h_id) VALUES(#{c_name},#{c_yield},#{c_earnings},#{c_amount},#{h_id})")
    boolean insertChange(Change change);
//修改
    @Update("update change_money c,investment_horizon h SET c.c_name=#{c_name},c.c_yield=#{c_yield},c.c_earnings=#{c_earnings},c.c_amount=#{c_amount},h.h_deadline=#{h_deadline},h.h_day=#{h_day} where c_id=#{c_id} and c.h_id=h.h_id")
    boolean updateChange(Change change);
//根据id进行查询
    @Select("select * from change_money c,investment_horizon h where c.c_id=#{c_id} and c.h_id=h.h_id")
    Change selectById(Integer c_id);
    @Delete("delete from change_money where c_id=#{c_id}")
    boolean deleteChange(Integer c_id);
}
